package com.chujian.sys.entity;

import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.chujian.SystemEchoConst;
import com.chujian.framework.annotation.echo.Echo;
import com.chujian.framework.core.IId;
import com.chujian.framework.core.IIdName;
import com.chujian.framework.core.base.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * 人员表
 *
 * @author chujian
 * @since 2021-08-06
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("sys_user")
@KeySequence("sys_user_seq")
public class SysUser extends BaseEntity implements IId, IIdName {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "用户ID ")
    @TableId("user_id")
    private Long userId;

    @ApiModelProperty(value = "用户真实姓名")
    @TableField("user_name")
    private String userName;

    @ApiModelProperty(value = "登录名")
    @TableField("login_name")
    private String loginName;

    @ApiModelProperty(value = "身份证")
    @TableField("id_card")
    private String idCard;

    @ApiModelProperty(value = "密码 ")
    @TableField("password")
    private String password;

    @ApiModelProperty(value = "盐加密 ")
    @TableField("password_salt")
    private String passwordSalt;

    @ApiModelProperty(value = "邮箱 ")
    @TableField("email")
    private String email;

    @ApiModelProperty(value = "手机号 ")
    @TableField("mobile")
    private String mobile;

    @ApiModelProperty(value = "出生日期")
    @TableField("birth")
    private LocalDate birth;

    @ApiModelProperty(value = "通信地址")
    @TableField("addr")
    private String addr;

    @ApiModelProperty(value = "性别（1：男 2:女） ")
    @TableField("sex")
    private Integer sex;

    @ApiModelProperty(value = "账套id")
    @TableField("ac_id")
    private Long acId;

    @ApiModelProperty(value = "产品id")
    @TableField("prod_id")
    private Long prodId;

    @ApiModelProperty(value = "公众号OPEN_ID ")
    @TableField("wx_mp_open_id")
    private String wxMpOpenId;

    @ApiModelProperty(value = "小程序OPEN_ID ")
    @TableField("wx_minip_open_id")
    private String wxMinipOpenId;

    @ApiModelProperty(value = "关联UNION_ID ")
    @TableField("wx_union_id")
    private String wxUnionId;

    @ApiModelProperty(value = "平台用户ID")
    @TableField("plat_union_id")
    private String platUnionId;

    @ApiModelProperty(value = "最后登录IP ")
    @TableField("last_login_ip")
    private String lastLoginIp;

    @ApiModelProperty(value = "最后登录MAC地址 ")
    @TableField("last_login_mac")
    private String lastLoginMac;

    @ApiModelProperty(value = "最后登录时间 ")
    @TableField("last_login_time")
    private LocalDateTime lastLoginTime;

    @ApiModelProperty(value = "最后登陆单位ID")
    @TableField("last_login_comp_id")
    private Long lastLoginCompId;

    @ApiModelProperty(value = "最后登陆ac")
    @TableField("last_login_ac_id")
    private Long lastLoginAcId;

    @ApiModelProperty(value = "最后登陆平台 1：PC 2：App 3：Applets")
    @TableField("last_login_plat_id")
    private Integer lastLoginPlatId;

    @ApiModelProperty(value = "微信昵称")
    @TableField("wx_nickname")
    private String wxNickname;

    @ApiModelProperty(value = "微信头像")
    @TableField("wx_head_url")
    private String wxHeadUrl;

    @ApiModelProperty(value = "微信性别")
    @TableField("wx_gender")
    private String wxGender;

    @ApiModelProperty(value = "是否锁定（0：未锁定 1：锁定） ")
    @TableField("lock_flag")
    private Boolean lockFlag;

    @ApiModelProperty(value = "是否公开")
    @TableField("public_flag")
    private Boolean publicFlag;

    @ApiModelProperty(value = "拼音")
    @TableField("pin_yin")
    private String pinYin;

    @ApiModelProperty(value = "部门ID")
    @TableField("dept_id")
    @Echo(value = SystemEchoConst.deptEchoService, targetField = "deptName")
    private Long deptId;

    @ApiModelProperty(value = "使用状态（0：禁用 1：启用） ")
    @TableField("status")
    private Boolean status;

    @ApiModelProperty(value = "查询项")
    @TableField("search_info")
    private String searchInfo;

    @ApiModelProperty(value = "来源id")
    @TableField("source_id")
    private String sourceId;

    @ApiModelProperty(value = "来源系统")
    @TableField("source_system")
    private String sourceSystem;

    // ++++++ 系统拓展 +++++++
    @TableField(exist = false)
    private Map<String, String> query = new HashMap<>();

    @Override
    public Long getId() {
        return this.userId;
    }

    @Override
    public void setId(Serializable id) {
        if (null != id) {
            this.userId = Long.parseLong("" + id);
        }
    }

    @Override
    public String getName() {
        return this.userName;
    }

    // ++++++ 业务拓展 +++++++
    @TableField(exist = false)
    private String deptName;

}
